<template>
	<view class="personal">
		<TopBar :indexflag="true" :combakflag="true" :lang="false" :bottom="true" :title="$t('ChangePassword')"
			:barstyle="colortopic()" Color="#fff"></TopBar>
		<view :class="i18nLocale=='ug'?' ug-from input-from':'input-from'">
			<view class="input-item">
				<view class="title">
					{{$t('OldPassword')}}
				</view>
				<u--input :placeholder="$t('OldPassword')" border="bottom" fontSize="28rpx"
					:adjustPosition='false' v-model="password_confirmation"></u--input>
			</view>
			<view class="input-item">
				<view class="title">
					{{$t('NewPassword')}}
				</view>
				<u--input :placeholder="$t('NewPassword')" border="bottom" fontSize="28rpx"
					:adjustPosition='false' v-model="password" ></u--input>
			</view>
		</view>
		<Contact style="margin-top:100rpx" :shopdata="mydata"></Contact>
		<u-toast ref="uToast" :message="notmessage"></u-toast>
		<view class="save-button" @click="changesave">{{$t('Save')}}</view>
	</view>
</template>

<script>
	import Contact from "@/components/Contact.vue"
		import {
			putpassword
		} from '@/api/shop.js';
	export default {
		components: {
			Contact
		},
		data() {
			return {
				mydata: {
					mobile: '17690927591',
					wechat: '17690927591'
				},
				password:'',
				password_confirmation:'',
				notmessage: '请仔细填写!',
			};
		},
		computed: {
			i18nLocale() {
				return this.$i18n.locale;
			},
		},
		methods: {
			changesave(){
				let that=this;
				if (that.password && that.password_confirmation) {
					putpassword({
						password:that.password,
						old_password:that.password_confirmation
					}).then((res) => {
						if (res.code == 200) {
							that.$refs.uToast.show({
								top: 0,
								message: this.$t('EditSuccessful'),
								color: '#fff',
								bgColor: '#f0ba53'
							})
							uni.removeStorageSync('shopinfo');
							uni.removeStorageSync('shoptoken');
							this.$store.commit('setShopinfo', '');
							this.$store.commit('setShoptoken', '');
							setTimeout(()=>{
								uni.reLaunch({
									url: '/pages/main/main'
								});
							},200)
						} else {
							that.$refs.uToast.show({
								top: 0,
								message: this.$t('EditFailed'),
								color: '#fff',
								bgColor: '#f0ba53'
							})
						}
					})
				}else{
					that.$refs.uToast.show({
						top: 0,
						message: this.$t('PleaseFillCarefully'),
						color: '#fff',
						bgColor: '#f0ba53'
					})
					return;
				}
			}
		}
	}
</script>

<style lang="scss">
	.personal {
		padding: $uni-spacing-padding-sm;
		box-sizing: border-box;

		.input-from {
			background-color: #fff;
			width: 100%;
			padding: 10rpx 20rpx;
			box-sizing: border-box;
			margin-top: 20rpx;
			border-radius: $uni-border-radius-lg;
			box-shadow: $uni-bg-shadow;

			.input-item {
				width: 100%;
				// display: flex;
				padding: $uni-spacing-padding-sm;
				box-sizing: border-box;

				input {
					font-size: $uni-font-size-base;

				}

				.title {
					color: $uni-color-title;
					font-size: $uni-font-size-base;
				}
			}
		}

		.selecet-addres {
			background-color: #fff;
			width: 100%;
			padding: 20rpx 40rpx;
			box-sizing: border-box;
			margin-top: $uni-spacing-margin-sm;
			border-radius: $uni-border-radius-lg;
			box-shadow: $uni-bg-shadow;
			color: $uni-color-title;
			font-size: $uni-font-size-base;



		}

		.no-address {
			margin-top: 100rpx;

			text {
				padding: 0rpx 20rpx;
			}
		}

		.address {
			// border-bottom: 2rpx solid;
			display: flex;
			margin-bottom: 20rpx;
			background-color: $uni-bg-color-box;
			width: 100%;
			padding: 30rpx 40rpx;
			box-sizing: border-box;
			margin-top: $uni-spacing-margin-sm;
			border-radius: $uni-border-radius-lg;
			box-shadow: $uni-bg-shadow;

			.left {
				width: 70%;
				display: flex;
				flex-direction: column;
				justify-content: center;
				font-size: $uni-font-size-sm1;

				.user {
					display: flex;

					.name {
						color: $uni-color-topic;
						font-weight: bold;
					}

					.pone {
						padding: 0rpx 40rpx;
						box-sizing: border-box;
					}

				}

				.address-title {
					margin-top: 10rpx
				}
			}

			.right {
				width: 30%;
				display: flex;
				align-items: center;
				justify-content: space-around;

				.raio {
					width: 50rpx;
					height: 50rpx;
					border-radius: 100%;
					border: 4rpx solid $uni-border-color;
					display: flex;
					justify-content: center;
					align-items: center;

				}

				.acradio {
					border: 4rpx solid $uni-color-topic;
					background-color: $uni-color-topic;
				}
			}

		}

		.save-button {
			width: 90%;
			margin: 20rpx auto;
			background-color: $uni-color-topic;
			color: #fff;
			font-size: $uni-font-size-lg;
			padding: $uni-spacing-padding-sm 0rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			border-radius: $uni-border-radius-lg;
			position: fixed;
			bottom: 5%;
			left: 5%;
		}
	}

	.ug-from {
		direction: rtl;

		/deep/ .uni-input-input {
			direction: rtl !important;
			text-align: right;
		}

		/deep/ .uni-input-placeholder {
			text-align: right;
		}
	}
</style>